function getFileList() {
	document.refreshFileList.action = 'getfilelist?from=index';
	document.refreshFileList.submit();

}

function changeSource() {

	if ($("#sourceFile").val() == "") {
		alert("Please choose a sourece file!");
	} else {
		var select = $("#sourceFile").val();
		document.refreshFileList.action = 'marshall?sourceFileName=' + select;
		document.refreshFileList.submit();
	}

}

function checkFile() {

	if ($("#fileforload").val() == "") {
		alert("upload file first");

	} else {
		var select = $("#filelocation").val();
		document.browse.action = 'upload?filetype=' + select;
		document.browse.submit();
	}

}

function changeTarget() {

//	var e = document.getElementById("selectTarget");
//	var strUser = e.options[e.selectedIndex].text;
//
//	switch (strUser) {
//	case 'Applicant':
//		document.getElementById("applicants").style.display = "block";
//		document.getElementById("jobCategory").style.display = "none";
//		document.getElementById("foods").style.display = "none";
//		break;
//	case 'Job Category':
//		document.getElementById("applicants").style.display = "none";
//		document.getElementById("jobCategory").style.display = "block";
//		document.getElementById("foods").style.display = "none";
//		break;
//	case 'foodTest':
//		document.getElementById("applicants").style.display = "none";
//		document.getElementById("jobCategory").style.display = "none";
//		document.getElementById("foods").style.display = "block";
//		break;
//	}
	document.targettype.action = "targettype";
	document.targettype.submit();
	
	
}

function openNewWindow() {
	var a;
	a = document.getElementById("applicant_age").value;
	var str = "result.jsp?result=" + a + "";
	window.open(str);
}

function datafilter(columnN) {

	var str = "datafilter.jsp?result=" + columnN;
	window.open(str);
}

function lookups(columnN) {

	// Added by Tom
	var Check = "checkEmpty";
	Check = Check + columnN;
	if (document.getElementById(Check).value == "") {
		alert("please mapping this column first");
	} else {

	var str = "getfilelist?result=" + columnN;
	window.open(str);
	}
}

function fxfunction(id) {
	var Check = "checkEmpty";
	Check = Check + id;

	if (document.getElementById(Check).value == "") {
		alert("please mapping this column first");
	} else {

		// changed by Yuan Huang
		var sendValue = $("#checkEmpty" + id).val();

		var str = "fxfunction.jsp?result=" + id + "&value=" + sendValue;
		window.open(str);
	}
}

function preView() {

	var str = "preView.jsp";
	window.open(str);
}

function viewChangelist() {

	var str = "FXModify";
	window.open(str);
}
function viewdataFilterlist() {
	var str = "DatafilterModify.jsp";
	window.open(str);
}

function viewlookupslist() {
	var str = "lookupsModify.jsp";
	window.open(str);
}

function showFinal() {

	var request = "?";
	$("#rightTable").find("input[type=text]").each(function(key, value) {

		request += $(value).attr("name");
		request += "=";
		request += $(value).val();
		request += "&";

	});

	request += "connectStr=" + $("#connectStr").val();

	var str = "ViewFinal" + request;
	window.open(str);
}

function checkStr() {
	var Str = document.getElementById("connectStr");
	if (Str.value.indexOf('\\') != -1) {
		alert("not support '\\' currently");
		document.getElementById("connectStr").value = "";
	}

}

function checkValue(length, id) {
	var textValue = document.getElementById(id).value;
	var splitValue = textValue.split(",");
	for (var i = 0; i < splitValue.length; i++) {
		if (isNaN(splitValue[i])) {
			alert("invalid input");
			document.getElementById(id).value = "";
		} else if (!(splitValue[i] % 1 === 0)) {
			alert("invalid input");
			document.getElementById(id).value = "";
		} else {
			if (parseInt(splitValue[i]) > parseInt(length)) {
				alert("you can only input left ID here")
				document.getElementById(id).value = "";
			}
		}
	}
}

function checkUpload(flag) {

	if (flag == "N") {
		alert("please choose your source file first");
		document.getElementById("fileUpload").focus();
	}

}

function checkFinal(flag) {

	if (checkRequire()) {
		if (flag == "N") {
			alert("please choose your source file first]");
		} else {
			alert("convert success");
			document.form1.action = 'submit';
			document.form1.submit();
		}
	}

}

function checkRequire() {
	var result = true;
	$("input[type=checkbox][for][checked]").each(function(key, value) {

		if ($("#" + $(value).attr("for")).val().length == 0) {
			result = false;

		}

	});

	if (!result)
		alert("required field is empty!");

	return result;

}